﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StuApart
{
    public partial class UserManage : Form
    {
        public UserManage()
        {
            InitializeComponent();
        }

        private void usersBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.usersBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.stuApartDataSet);
            MessageBox.Show("保存成功！");
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“stuApartDataSet.Users”中。您可以根据需要移动或移除它。
            this.usersTableAdapter.Fill(this.stuApartDataSet.Users);

        }

        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            if (usersDataGridView.SelectedRows.Count == 0)
            {
                MessageBox.Show("请先单击最左边的空白处，选择要删除的行！");
            }
            else
            {
                if (MessageBox.Show("你确定要删除吗？", "小心", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    for (int i = 0; i < usersDataGridView.SelectedRows.Count; i++)
                    { usersBindingSource.RemoveAt(usersDataGridView.SelectedRows[i].Index); }

                }
            }
        }

        private void usersBindingNavigator_RefreshItems(object sender, EventArgs e)
        {

        }

       
    }
}
